package com.bwf.generic;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/24 10:23
 * @Copyright 博为峰
 */
public class GenericDemo01 {
    public static void main(String[] args) {
        final ArrayList<String> arrayList = new ArrayList<String>();
        arrayList.add("a");
        arrayList.add("b");
//        arrayList.add(6);//自动装箱 Object o = 6; Object o = new Integer(6)

        final Iterator<String> iterator = arrayList.iterator();
        while (iterator.hasNext()){
//            String s = (String)iterator.next();//ClassCastException
            final String next = iterator.next();
            System.out.println(next);
        }

    }
}
